<form class="layui-form " action="" lay-filter="dataForm">
    <input type="hidden" name="id">
    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" name="title" lay-verify="required" autocomplete="off" placeholder="请输入标题" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">来源</label>
        <div class="layui-input-inline">
            <label class="layui-form-label" style="text-align: left;padding-left: 0; width:600px;">
                {$come_from|default='平台'}
            </label>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">置顶</label>
        <div class="layui-input-block">
            <input type="checkbox" name="is_top" value="1" lay-skin="switch" lay-text="是|否">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">发布时间</label>
        <div class="layui-input-inline">
            <input type="text" name="time" id="time" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">截止时间</label>
        <div class="layui-input-inline">
            <input type="text" name="over_time" id="over_time" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">内容</label>
        <div class="layui-input-block">
            <textarea name="content" placeholder="请输入内容" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="dataSubmit">保存</button>
        </div>
    </div>
</form>
<script>
    layui.use(['form', 'http', 'laydate'], function () {
        var form = layui.form;
        var http = layui.http;
        var $ = layui.$;
        var laydate = layui.laydate;
        laydate.render({
            elem: '#time',
            type: 'datetime'
        });
        laydate.render({
            elem: '#over_time',
            type: 'datetime'
        });

        //表单初始赋值
        form.val('dataForm', {
            "id": "{$id}",
            "title": "{$title}",
            "content": "{$content}",
            "is_top": "{$is_top?'1':''}",
            "time": "{$time}",
            "over_time": "{$over_time}",
        })
        //监听提交
        form.on('submit(dataSubmit)', function (data) {
            http.post('/setting/noticeedit', data.field, function (res) {
                if (res.code == 0) {
                    parent.layui.table.reload('dataTable');
                    parent.layer.closeAll('page');
                }
            }, $(this))
            return false;
        })
    })
</script>